Imports Microsoft.VisualBasic
Public Class Helpers
    Public Shared Function GetThemes() As String()
        If Not IsNothing(HttpContext.Current.Cache("SiteThemes")) Then
            Return HttpContext.Current.Cache("SiteThemes")
        Else
            Dim ThemesPath As String
            ThemesPath = HttpContext.Current.Server.MapPath("~/App_Themes")
            Dim Themes() As String
            Themes = System.IO.Directory.GetDirectories(ThemesPath)
            For i As Integer = 0 To Themes.GetUpperBound(0)
                Themes(i) = System.IO.Path.GetFileName(Themes(i))
            Next
            Dim dep As New CacheDependency(ThemesPath)
            HttpContext.Current.Cache.Insert("SiteThemes", Themes, dep)
            Return Themes
        End If
    End Function
    ' Converts the input plain-text to HTML version, replacing carriage returns
    ' and spaces with <br /> and &nbsp;
    Public Shared Function ConvertToHtml(ByVal content As String) As String
        content = HttpUtility.HtmlEncode(content)
        content = content.Replace("  ", "&nbsp;&nbsp;").Replace( _
           "\t", "&nbsp;&nbsp;&nbsp;").Replace("\n", "<br>")
        Return content
    End Function
End Class


